import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_study/model/topic_model.dart';

class TopicWidgetItem extends StatelessWidget {
  final TopicItemModel itemModel;

  const TopicWidgetItem({Key key, @required this.itemModel}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Padding(
          padding: EdgeInsets.all(10),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(4),
            child: CachedNetworkImage(
              width: MediaQuery.of(context).size.width,
              height: 200,
              imageUrl: itemModel.data.image,
              errorWidget: (context, url, error) {
                return Image.asset('images/img_load_fail.png');
              },
              fit: BoxFit.cover,
            ),
          ),
        ),
      ],
    );
  }
}
